<?php

// include a library to activemq
require 'Stomp.php';
// make a connection
$con = new Stomp("tcp://127.0.0.1:61613");
// connect
$con->connect();
// variable remote
$voto = $_POST['user'];
$voto = $_POST['card_number'];
$voto = $_POST['card_type'];
// send a message to the queue
try {
$con->send("LINUX", "$user-$card_number-$card_type");
echo "Sent message with body 'Pago realizado'\n <br><a href=menu.html>Volver</a>";
 } catch (StompException $e) {
 echo "guest cannot send\n";
 echo $e->getMessage() . "\n";
 echo $e->getDetails() . "\n\n\n";
 }
// subscribe to the queue
//$con->subscribe("LINUX");
// receive a message from the queue
//$msg = $con->readFrame();

// do what you want with the message
//if ( $msg != null) {
//    echo "Received message with body '$msg->body'\n";
    // mark the message as received in the queue
//    $con->ack($msg);
//} else {
//    echo "Failed to receive a message\n";
//}

// disconnect
$con->disconnect();
// include a library to activemq
//require 'Stomp.php';
// make a connection
$con = new Stomp("tcp://127.0.0.1:61613");
// connect
$con->connect();
// subscribe to the queue
$con->subscribe("LINUX");
// receive a message from the queue
$msg = $con->readFrame();
	// do what you want with the message
	if ( $msg != null) {
		//echo "Received message with body '$msg->body'\n";
		echo "$msg";
		// mark the message as received in the queue
		$con->ack($msg);
	} else {
	echo "Failed to receive a message\n";
	}

	// disconnect
	$con->disconnect();
	$connecta = mysql_pconnect("127.0.0.1","root","");
	if ($connecta) {
	if(mysql_select_db("test", $connecta)) {
	mysql_query("update cuenta_usuario, MyUser set cuenta=cuenta-100 where id_usuario=MyUser.ID; ('','$msg->body')");
	return true;
	}
	}
?>
